home *** CD-ROM | disk | FTP | other *** search
- Path: qcd.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with stringcopy
- Date: 6 Jan 1996 19:24:17 GMT
- Organization: Los Alamos National Laboratory
- Distribution: world
- Message-ID: <4cmi91$irn@newshost.lanl.gov>
- References: <4clguu$9fs@eagle.novo.dk> <yewvimppjz5.fsf@hyll.idt.unit.no> <4cmafq$bm5@clarknet.clark.net>
- NNTP-Posting-Host: qcd.lanl.gov
-
- In article <4cmafq$bm5@clarknet.clark.net>, eamick@clark.net (Eric Amick)
- writes:
- |> Amund Tveit (amundt@pvv.unit.no) wrote:
- <snip>
- |> >char *Stringcopy(char *source, int startpos, size_t length)
- |> >{
- |> > char tmpstring[SIZEBIGENOUGH];
- |> > strncpy((char *)(source+startpos),tmpstring,length);
- |> > return tmpstring;
- |> >}
- |>
- |> This won't work as written; the first two arguments to strncpy() are
- |> reversed. The cast is also unnecessary.
-
- Those are probably typographical errors. The possibility of declaring
- SIZEBIGENOUGH is always an optimistic proposition; but, most importantly,
- this routine contains one of the very common and absolutely disastrous
- beginner errors! Anyone?
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-